/**
 * Copyright 2015 Qiyi Inc. All rights reserved.
 *
 * @file:   Channel.Config.js
 * @path:   js-src/Channel/
 * @desc:   Channel公共配置集合，键值对象
 *          一级键名大写，之间名采用驼峰式
 * @author: jiegang@qiyi.com
 * @date:   2015-01-11
 */
///import js-src/lib/
///import js-src/com/
qui(function (require, exports, module) {
    Channel.Config = $.extend({}, Ancestor.Config, {
        PLAY_TYPE: ["未知", "点播", "直播"],

        SEARCH: {

            rules: {
                qipuId: {

                    digits: true
                }


            },


            messages: {
                "qipuId": {
                    "digits": "请输入正确的奇谱ID"
                }
            }

        },


        EDIT: {

            rules: {
                name: {
                    required: true,
                    maxlength: 40
                },
                //  shortName: {required:true,maxlength:10},
                universalCode: {
                    required: true,
                    alphaNumber: true
                },

                maxPlaybackPeriod: "required",
                logoUrl: "required",
                carousel_table_no: {
                    required: true,
                    digits: true
                }
            },


            messages: {
                "name": {
                    "required": "直播频道名称不能为空",
                    "maxlength": "最多输入40个字符"
                },

                "universalCode": {
                    "required": "节目单代码不能为空",
                    "alphaNumber": "请输入正确的节目单代码"
                },

                /* "shortName":{
                 "required": "频道简称不能为空",
                 "maxlength":"最多输入10个字符"
                 },



                 "type":{
                 "required": "频道类型不能为空"
                 },

                 "qitanId":{"digits": "请输入正确的奇谈ID"},


                 "orderBy":{
                 "required": "频道排序不能为空",
                 "digits": "请输入正确的排序"
                 },*/

                "maxPlaybackPeriod": {
                    "required": "最大回看时间不能为空"
                },
                /*
                 "ppsBaikeId":{"digits": "请输入正确的pps百科id"},
                 */
                "logoUrl": {
                    "required": "请上传频道图标"
                },
                "carousel_table_no": {
                    "digits": "请输入正确的轮播台台号",
                    "required": "轮播台台号不能为空"
                    //  "isExists" : "此轮播台台号已存在,请换一个"
                }
            },

            onkeyup: function (element) {
                var $element = $(element);
                var name = $element.attr('name');
                var cb = {
                    onkeyup: true
                };

                if (typeof cb.onkeyup == 'function') {
                    cb.onkeyup($element, this);
                } else if (cb.onkeyup) {
                    $element.valid();
                }
            },
            onfocusout: function (element) {
                var $element = $(element);
                var name = $element.attr('name');
                var cb = {
                    onfocusout: true
                };

                if (typeof cb.onfocusout == 'function') {
                    cb.onfocusout($element, this);
                } else if (cb.onfocusout) {
                    $element.valid();
                }
            }


        },

        TABLE_COLMODEL_CONFIG: {
            id: {
                name: 'id',
                index: 'id',
                title: false,
                width: 100,
                align: 'center',
                sortable: false
            },

            qipuId: {
                name: 'qipuId',
                index: 'qipuId',
                title: false,
                width: 80,
                align: 'center',
                sortable: false,
                formatter: function (v, o, r) {
                    return Channel.Util.formatter.qipuId(v, r);
                }
            },
            name: {
                name: 'name',
                index: 'name',
                width: 120,
                align: 'center',
                title: false,
                sortable: false,
                formatter: function (v, o, r) {
                    return Channel.Util.formatter.name(v, r);
                }
            },

            liveType: {
                name: 'liveType',
                index: 'liveType',
                title: false,
                width: 80,
                align: 'center',
                sortable: false,
                formatter: function (v, o, r) {
                    return Channel.Util.formatter.liveType(v, r);
                }

            },


            type: {
                name: 'type',
                index: 'type',
                title: false,
                width: 80,
                sortable: false,
                align: 'center',
                formatter: function (v, o, r) {
                    return Channel.Util.formatter.channelType(v, r);
                }
            },

            universalCode: {
                name: 'universalCode',
                index: 'universalCode',
                title: false,
                width: 70,
                align: 'center',
                sortable: false,
                formatter: function (v, o, r) {
                    return Channel.Util.formatter.universalCode(v, r);
                }

            },

            defaultLogoUrl: {
                name: 'defaultLogoUrl',
                index: 'defaultLogoUrl',
                title: false,
                sortable: false,
                width: 100,
                align: 'center',
                formatter: function (v, o, r) {
                    return Channel.Util.formatter.defaultLogoUrl(v, r);
                }

            },

            maxPlaybackPeriod: {
                name: 'maxPlaybackPeriod',
                index: 'maxPlaybackPeriod',
                width: 80,
                align: 'center',
                sortable: false,
                title: false,
                formatter: function (v, o, r) {
                    return Channel.Util.formatter.maxPlaybackPeriod(v, r);
                }
            },

            isEnable: {
                name: 'isEnable',
                title: false,
                sortable: false,
                width: 60,
                align: 'center',
                formatter: function (v, o, r) {
                    return Channel.Util.formatter.isEnable(v, r);
                }
            },
            isMemeberFree: {
                name: 'isMemeberFree',
                sortable: false,
                title: false,
                width: 60,
                align: 'center',
                formatter: function (v, o, r) {
                    return Channel.Util.formatter.isMemeberFree(v, r);
                }
            },

            status: {
                name: 'status',
                sortable: false,
                title: false,
                width: 70,
                align: 'center',
                formatter: function (v, o, r) {
                    return Channel.Util.formatter.status(v, r);
                }
            },

            operate: {
                name: 'operate',
                width: 210,
                sortable: false,
                title: false,
                align: 'center',

                formatter: function (v, o, r) {
                    return Channel.Util.formatter.operate(v, r);
                }

            },

            addTime: {
                name: 'addTime',
                index: 'addTime',
                sortable: false,
                title: false,
                width: 120,
                align: 'center'
            },


            operator: {
                name: 'operator',
                index: 'operator',
                sortable: false,
                title: false,
                width: 60,
                align: 'center',
                formatter: function (v, o, r) {
                    return Channel.Util.formatter.operator(v, r);
                }
            },
///
            log_id: {
                name: 'id',
                index: 'id',
                title: false,
                sortable: false,
                hidden: true
            },
            log_addTime:{
                name: 'addTime',
                index: 'addTime',
                sortable: false,
                title: false,
                width: 150,
                align: 'center'
            },
            log_user: {
                name: 'user',
                index: 'user',
                sortable: false,
                title: false,
                width: 150
            },
            log_type: {
                name: 'type',
                index: 'type',
                sortable: false,
                title: false,
                width: 120,
                formatter: function (v, o, r) {
                    return Channel.Util.formatter.log_type(v, r);
                }
            },
            log_descr: {
                name: "descr",
                index: 'descr',
                title: false,
                width: 450,
                sortable: false
            }
        },
        TABLE: { //素材库查询列表配置
            url: '/api/channel/list',
            //datatype:"jsonp",
            multiselect: false,

            loadtext: '加载中...',
            loadui: 'block',
            rowNum: 10,
            loadBeforeSend: function (xhr, settings) {
                var auth = Ancestor.Util.getAuth(Ancestor.Config.EPG_AUTH.list);
                xhr.setRequestHeader('Sign', auth.sign);
                xhr.setRequestHeader("Time", auth.clientTime);
                xhr.setRequestHeader("From", auth.from);
                return true;
            },
            prmNames: {
                page: "pageNo",
                rows: "pageSize"
            },
            colNames: ["ID", "奇谱ID", "频道名称", "直播类型", "频道类型", "节目单代码", "logo",
                "回看时间", "启用状态", "划价状态", "操作",
                "创建日期", "操作历史"
            ],

            colModel: ['id', 'qipuId', 'name', 'liveType', 'type', 'universalCode', 'defaultLogoUrl', 'maxPlaybackPeriod',
                'isEnable', 'status', 'operate', 'addTime', 'operator'
            ]
        },

        TABLE_LOG: {
            url: "/api/channel/loglist",
            multiselect: false,
            loadtext: '加载中...',
            loadui: 'block',
            rowNum: 50,
            mtype: "post",
            loadBeforeSend: function (xhr, settings) {
                var auth = Ancestor.Util.getAuth("/channel/loglist");
                xhr.setRequestHeader('Sign', auth.sign);
                xhr.setRequestHeader("Time", auth.clientTime);
                xhr.setRequestHeader("From", auth.from);
                return true;
            },
            datatype: "local",
            prmNames: {
                page: "pageNo",
                rows: "pageSize"
            },
            colNames: ["ID", "操作时间", "人员", "动作", "备注"],
            colModel: ['log_id', "log_addTime", "log_user" , "log_type" , "log_descr"],
            pager: "#log_pager"
        },

        SLICE_DELAY_CHECK: {
            msg: '修改延时时间后需要手动修改节目单时间',
            oldValue: null,
            headUrl: null
        },

        AUTOMATION_TYPE: {
            0: "手动节目单",
            1: "自动化节目单(专辑)",
            2: "自动化节目单(节目)"
        },

        USER_COUNT: {
            0: "小于5w",
            1: "5-30w",
            2: "30-100w",
            3: "大于100w"
        },

        /* alternatePlayCollection remote api */
        APC_CONFIG: (function () {
            var prefix = auth.dev() ? 'http://10.10.5.161:50002/' : 'http://bake.produce.qiyi.domain:50002/';
            return {
                apc_add: prefix + "add",
                apc_delete: prefix + "delete",
                apc_info: prefix + "info"
            }
        })(),
        AUTH_CHECK: {
            technologist: false
        },
        TempChannel:null,
        NormalChannel:null,
        Carousel:null
    });
});